package ru.spb.osll.myfit.client.dialog;

import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.DialogBox;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.VerticalPanel;

public class ErrorDialog extends DialogBox {
  /**
   * The message displayed to the user when the server cannot be reached or
   * returns an error.
   */
  private static final String SERVER_ERROR = "An error occurred while "
      + "attempting to contact the server. Please check your network " + 
      "connection and try again.";
  
  public ErrorDialog() {
    setText("Remote Procedure Call");
    setAnimationEnabled(true);
    final Button closeButton = new Button("Close");
    closeButton.getElement().setId("closeButton");
    final HTML serverResponseLabel = new HTML();
    VerticalPanel dialogVPanel = new VerticalPanel();
    dialogVPanel.addStyleName("dialogVPanel");
    dialogVPanel.setHorizontalAlignment(VerticalPanel.ALIGN_RIGHT);
    dialogVPanel.add(closeButton);
    dialogVPanel.add(serverResponseLabel);
    setWidget(dialogVPanel);
    setText("Remote Procedure Call - Failure");
    serverResponseLabel.addStyleName("serverResponseLabelError");
    serverResponseLabel.setHTML(SERVER_ERROR);

    closeButton.addClickHandler(new ClickHandler() {
      public void onClick(ClickEvent event) {
        ErrorDialog.this.hide();
      }
    });
  }
  
  public void showWithMessage(String message) {
    setMessage(message);
    super.show();
  }
  
  public void setMessage(String message){
    
  }
  
  

}
